<?php
/**
 * Created by PhpStorm.
 * User: mikol
 * Date: 2018/8/2 0002
 * Time: 16:50
 */

namespace app\api\controller;


class Home extends Base
{

    public function menu()
    {
        $access = $this->redis->get('access_token');
        $url = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token='.$access;
        $data = [
            'button'=>[
                [
                    'type' =>'view',
                    'name' =>'主页',
                    'key'  =>'0001',
                    'url'  =>'http://www.yckl.xyz/index.php/api/home/index',
                ]
            ]
        ];

        $res = postUrl($url,json_encode($data,JSON_UNESCAPED_UNICODE));
        return $res;
    }

    public function index()
    {
        $data = [
          'appid' => $this->appId,
          'redirect_uri' => 'http://www.yckl.xyz/index.php/index/index/home',
          'response_type' => 'code',
          'scope' => 'snsapi_base',
          'state' => 'home',
        ];
        $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?'.http_build_query($data).'#wechat_redirect';

    }
}